
namespace DA.AnimGraph.Editor {

    [NodeMenuItem(typeof(AGANode_Clip), "Clip")]
    internal class NodeView_Clip : NodeViewBase {

        public override string titleText => "Clip";
        protected override NodeViewInspectorSourceBase dataSource => inspectorData;
        NodeViewInspector_Clip inspectorData;

        internal override void Init(AGAHandle_Node handle, AnimGraphView graphView, AGEEnvironment ageContext) {
            inspectorData = new NodeViewInspector_Clip();
            inspectorData.SetHandle(handle);
            base.Init(handle, graphView, ageContext);
        }

    }


    internal class NodeViewInspector_Clip : NodeViewInspectorSourceBase {
        [InspectorField] public AGAFieldModel_ClipLink clip;
        [InspectorField(label: "播放速度")] public AGAFieldModel_FloatLink playbackSpeed;

        protected override void LoadFromModel() {
            var model = handleKeeper.handle.data.modelProperty as AGANodeModel_Clip;
            clip = model.clip;
            if (model.playbackSpeed == null) {
                model.playbackSpeed = new AGAFieldModel_FloatLink() { defaultValue = 1f };
            }
            playbackSpeed = model.playbackSpeed;
        }

        protected override void SaveToModel() {
            handleKeeper.handle.SetDirty();
        }
    }


}
